import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)
const state = {
  goodList: [
    {
      name: '诸葛亮',
      price: 1000,
      num: 1,
      checked: false,
    },
    {
      name: '蔡文姬',
      price: 1500,
      num: 1,
      checked: false,
    },
    {
      name: '妲己',
      price: 2000,
      num: 1,
      checked: false,
    },
    {
      name: '鲁班',
      price: 2200,
      num: 1,
      checked: false,
    },
  ],
}
const getters = {
  setAll(val) {
    return (val.goodList.checked = false)
  },
}
const mutations = {
  delete(state, val) {
    state.goodList = state.goodList.filter((item, index) => index !== val)
    // console.log(index)
  },
}
const actions = {}
const modules = {}
export default new Vuex.Store({
  state,
  getters,
  mutations,
  actions,
  modules,
})
